import matplotlib.pyplot as plt
import numpy as np
import os

def ACT():
    x_data = ['MID', 'EDF', 'INS', 'SRPT', 'FB', 'THR', 'OPTFB', 'RM', 'SEDF', 'SALL', 'FIFO', 'FEDF']
    ind = np.arange(len(x_data))
    y_data1 = [45.478768355352514, 45.45934900618088, 45.16853374528319, 40.42795226084374, 45.384834528160155, 45.384834528160155, 45.3159689243405, 33.5533456227437, 42.76665010403372, 40.847270220316375, 56.16340671892542, 55.81383278555447]
    y_data2 = [50.803634111088165, 46.559123079578804, 45.80006829434864, 41.92455590386625, 46.15981420953036, 46.15981420953036, 46.280414150129424, 37.19541446208113, 43.568962510898, 42.43005612138848, 59.21102284011916, 58.98907646474677]
    w = 0.2
    ax = plt.subplot(111)
    a = ax.bar(ind,y_data1,width=0.2,align='center',color='red')
    b = ax.bar(ind+w,y_data2,width=0.2,align='center', color='lightseagreen')
    ax.set_xticks(ind+w)
    ax.set_xticklabels( ('MID', 'EDF', 'INS', 'SRPT', 'FB', 'THR', 'OPTFB', 'RM', 'SEDF', 'SALL', 'FIFO', 'FEDF') )
    plt.legend((a,b),('ave ACT','worst ACT'))
    plt.autoscale(tight=True)
    plt.title('The average/worst ACT')
    plt.tight_layout()
    graph_path = os.path.dirname(os.path.abspath(__file__)) + '/graph/'
    if not os.path.isdir(graph_path):
        os.makedirs(graph_path)
    file_name = graph_path + __file__.split('/')[-1].split('.')[0]
    plt.savefig(f"{file_name}.pdf", bbox_inches='tight')
    plt.close()


if __name__ == '__main__':
    ACT()